//
//  CustomPicCollectionCell.m
//  YouGoWeGo
//
//  Created by LiuFei on 14/11/20.
//  Copyright (c) 2014年 LiuFei. All rights reserved.
//

#import "CustomPicCollectionCell.h"

#import "UIImageView+WebCache.h"
#import "AreaModel.h"
@implementation CustomPicCollectionCell

- (void)dealloc
{
    [_model release];
    [_image release];
    [self removeObserver:self forKeyPath:@"model"];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2.png"]];
        [_image setFrame:CGRectMake(10, 10, 100, 100)];
        
        
        
        [self addSubview:_image];
        [_image release];
        
        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        
    }
    return self;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        
        [self.image setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", self.model.photo_s]]];

    }
}

@end
